import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;

class LineInfo {
	int m_lineNumber;
	String m_line;
	String m_key;
	
	public LineInfo(int lineNumber, String line, String key) {
		m_lineNumber = lineNumber;
		m_line = line;
		m_key = key;
	}
};

public class FindString {
	
	static String[] s_keys = {
		"sendTextMessage",
		"sendMultipartTextMessage",
		"abortBroadcast",
		"content://sms/inbox",
		"getLine1Number",
		"getAccountsByType",
		"com.android.contacts",
		"ContactsContract.CommonDataKinds.Phone.NUMBER",
		"getDisplayMessageBody",
		"getInstalledPackages",
		"chmod",
		"getLastKnownLocation",
		"getNeighboringCellInfo",
	};
	
	static void Log(String msg) {
		System.out.println(msg);
	}
	
	static void showResult(File file, ArrayList list) {
		int size = list.size();
		if (size <= 0) return;
		
		Log("\n" + file.getAbsolutePath() + "(" + size + " hits)");
		
		LineInfo lineInfo;
		for (int i = 0; i < size; i++) {
			lineInfo = (LineInfo) list.get(i);
			Log("Line " + lineInfo.m_lineNumber + ": [" + lineInfo.m_key + "] " + lineInfo.m_line);
		}
	}
	
	static void processFile(File file) {
		BufferedReader reader;
		
		try {
			reader = new BufferedReader(new FileReader(file));
			String line;
			int lineNumber = 0;
			ArrayList list = new ArrayList();
			
			while ((line = reader.readLine()) != null) {
				lineNumber++;
				
				for (int i = 0; i < s_keys.length; i++)
					if (line.indexOf(s_keys[i]) > -1) {
						list.add(new LineInfo(lineNumber, line, s_keys[i]));
					}
			}
			
			showResult(file, list);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	static void processDirectory(File directory) {
		File[] files = directory.listFiles();
			
		File file;
		for (int i = 0; i < files.length; i++) {
			file = files[i];
			
			if (file.isDirectory())
				processDirectory(file);
			else if (file.isFile()) {
				processFile(file);
			}
		}
	}

	public static void main(String[] args) {
		File dir = new File("L:/test.apk.dex2jar.src");
		processDirectory(dir);
	}
}
